package com.xu.cloud.common.sequence.wrapper;

import com.xu.cloud.common.sequence.ISequence;
import com.xu.cloud.common.util.LocalDateTimeUtil;

/**
 * 时间格式化序列号生成器
 *
 * @author xuguan
 * @since 2025/2/12
 */
public class DateTimeFormatSequenceWrapper implements ISequence {
    private final ISequence sequence;
    private String pattern = LocalDateTimeUtil.PURE_DATE_PATTERN;

    public DateTimeFormatSequenceWrapper(ISequence sequence) {
        this.sequence = sequence;
    }

    public String getPattern() {
        return pattern;
    }

    public void setPattern(String pattern) {
        this.pattern = pattern;
    }

    @Override
    public String nextId() {
        final String fmtCurrent = LocalDateTimeUtil.fmtCurrent(pattern);
        return fmtCurrent + sequence.nextId();
    }
}
